<h1>Attachments</h1>

<style type="text/css">
  .progressBar .border { background-color: white; border: 0px; width: 100%; }
  .progressBar .background { background-color: #333; height: 18px; width: 0%; }
</style>

<%= render :partial => "page/header" %>

<div id="SingleContent">
  <table cellspacing="0" width="90%" class="tableview">
    <tr>
      <th>名称</th>
      <th width="60">大小</th>
      <th width="80">创建人</th>
      <th width="80">日期</th>
      <th>描述</th>
      <th>&nbsp;</th>
    </tr>
      <% @attachments.each do | attach | %>
    <tr>
      <td>
        <%= link_to attach.name, :action=>'download', :id=>attach.id %>
      </td>
      <td width="50" nowrap style="text-align:right;"><span><%= size_to_s attach.size %></span></td>
      <td><span><%= url_for_user attach.user%></span></td>
      <td><span><%= time_to_str attach.created_at %></span></td>
      <td><span><%= attach.description %></span></td>
      <td>
        <%= link_to '删除', {:action=>'delete', :id=>attach.id}, :confirm => "真的删除该附件么？" %>
      </td>
    </tr>
      <% end %>
  </table>
  <br/>
  <br/>


  <%= form_tag_with_upload_progress({:action => 'upload'}, { 
    :finish => "$('message').innerHTML = arguments[0]" })%>
    <table class="tableview" cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <th>&nbsp;</th>
        <th><span style="font: bold 14px Verdana, sans-serif;">添加文件</span></th>
        <th>描述</th>
      </tr>
      <tr valign="top">
        <td valign="top">1.</td> 
        <td width="10%" nowrap >
          <%= file_field 'document', 'file' %>
        </td>
        <td>
          <input value="" maxlength="255" type="text" size="50" name="comment">
          <span class="smalltext">(可选)</span>
        </td>
      </tr>
    </table>
    <table cellpadding="0" cellspacing="20" border="0" width="100%">
      <tr>
        <td align="center">
          <%= submit_tag '添加文件' %>
      </tr>
    </table>
  <%= upload_status_tag %>
  <input type="hidden" name="page_id" value="<%= @page.id %>"/>
  <%= end_form_tag %>
  <div id="message"><%= @message %></div>
</div>

